package com.gl.rent;

import com.haixiaoke.saas.repository.core.AjaxResult;
import com.haixiaoke.saas.repository.core.BaseController;
import com.haixiaoke.saas.repository.core.page.TableDataInfo;
import com.haixiaoke.saas.repository.pojo.PayType;
import com.haixiaoke.saas.repository.service.IPayTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 押付方式Controller
 *
 * @author 嗨小克
 * @date 2023-05-23
 */
@RestController
@RequestMapping("/base/payType")
public class PayTypeController extends BaseController {
    @Autowired
    private IPayTypeService payTypeService;

    /**
     * 查询押付方式列表
     */
    @GetMapping("/list")
    public TableDataInfo list(PayType payType) {
        startPage();
        List<PayType> list = payTypeService.selectPayTypeList(payType);
        return getDataTable(list);
    }

    /**
     * 获取押付方式详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(payTypeService.selectPayTypeById(id));
    }

    /**
     * 新增押付方式
     */
    @PostMapping
    public AjaxResult add(@RequestBody PayType payType) {
        return toAjax(payTypeService.insertPayType(payType));
    }

    /**
     * 修改押付方式
     */
    @PutMapping
    public AjaxResult edit(@RequestBody PayType payType) {
        return toAjax(payTypeService.updatePayType(payType));
    }

    /**
     * 删除押付方式
     */
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(payTypeService.deletePayTypeByIds(ids));
    }
}
